package dispatcher.gui.state;

import java.awt.event.ActionListener;
import java.util.ArrayList;

import state.group.events.EventCollection;

/**
 * This class is the super state handler class
 * @author Caleb
 *
 */
public abstract class StateHandler {

	protected ArrayList<ActionListener> listener;

	/**
	 * The main constructor
	 */
	public StateHandler() {
		listener = new ArrayList<ActionListener>();
	}

	/**
	 * This method will added listeners
	 * @param e The listener to be added
	 */
	public synchronized void addListener(ActionListener e) {
		
		listener.add(e);
	}

	/**
	 * This method will remove listeners
	 * @param e The listener to be removed
	 */
	public synchronized void removeListener(ActionListener e) {
		listener.remove(e);
	}
	
	/**
	 * This method is called when a new list of events have occurred and the status needs
	 * to be updated
	 * @param collection The collection of events will update the local status
	 */
	public abstract void updateEvents(EventCollection collection);

}